import { configureStore } from '@reduxjs/toolkit';
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
import { globalStatusReducer, globalStatusAction } from './reducer/globalStatus';
import { userInfoReducer, userInfoAction } from './reducer/userInfo';


export {
    userInfoAction,
    globalStatusAction,
};


export const store = configureStore({
    reducer: {
        globalStatus: globalStatusReducer,
        userInfo: userInfoReducer,
    },
});


// spatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>;
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;

// Use throughout your app instead of plain `useDispatch` and `useSelector`
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;